package com.drojian.demo1.test4;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.drojian.demo.R;
import com.drojian.demo1.pojo.Fruit;

import java.util.List;

public class MyGridViewAdapter extends BaseAdapter {
    private List<Fruit> datas;
    private Context context;

    public MyGridViewAdapter(Context context, List<Fruit> datas) {
        this.context=context;
        this.datas=datas;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {

        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_recyclerview, null);
        ImageView viewById = view.findViewById(R.id.imageId);
        TextView viewByName= view.findViewById(R.id.imageName);
        viewById.setImageResource(datas.get(position).getId());
        viewByName.setText(datas.get(position).getName());
        return view;
    }
}
